import 'package:efood_multivendor/helper/size_config.dart';
import 'package:efood_multivendor/util/dimensions.dart';
import 'package:efood_multivendor/util/styles.dart';
import 'package:flutter/material.dart';

class CancellationButton extends StatelessWidget {
  final Function()? onPressed;
  final String buttonText;
  final bool transparent;
  final EdgeInsets? margin;
  final double? height;
  final double? width;
  final double? fontSize;
  final double radius;
  final IconData? icon;
  CancellationButton(
      {this.onPressed,
      required this.buttonText,
      this.transparent = false,
      this.margin,
      this.width,
      this.height,
      this.fontSize,
      this.radius = Dimensions.RADIUS_SMALL * 2.1,
      this.icon});

  @override
  Widget build(BuildContext context) {
    final ButtonStyle _flatButtonStyle = TextButton.styleFrom(
      backgroundColor: Colors.white,
      minimumSize: Size(width ?? Dimensions.WEB_MAX_WIDTH, height ?? 50),
      padding: EdgeInsets.zero,
      shape: RoundedRectangleBorder(
        borderRadius: BorderRadius.circular(radius),
      ),
    );

    return Center(
        child: SizedBox(
            width: width != null ? width : Dimensions.WEB_MAX_WIDTH * 2.9,
            child: Padding(
                padding: margin ?? EdgeInsets.all(0),
                child: GestureDetector(
                  onTap: onPressed,
                  child: Container(
                    height: height != null ? height : 6.h,
                    decoration: BoxDecoration(
                        borderRadius: BorderRadius.circular(radius),
                        color: Colors.white,
                        border: Border.all(color: Colors.black)
                        //Theme.of(context).disabledColor, width: 2)

                        // gradient: LinearGradient(
                        //   colors: [Color(0xffff8022), Color(0xffff2222)],
                        // )
                        ),
                    child: Row(
                        mainAxisAlignment: MainAxisAlignment.center,
                        children: [
                          icon != null
                              ? Padding(
                                  padding: EdgeInsets.only(
                                      right:
                                          Dimensions.PADDING_SIZE_EXTRA_SMALL),
                                  child: Icon(icon,
                                      color: transparent
                                          ? Theme.of(context).primaryColor
                                          : Theme.of(context).cardColor),
                                )
                              : SizedBox(),
                          transparent
                              ? Text(buttonText,
                                  textAlign: TextAlign.center,
                                  style: sfBold.copyWith(
                                    color: Colors.black,
                                    fontSize: fontSize != null
                                        ? fontSize
                                        : Dimensions.fontSizeLarge,
                                  ))
                              : Text(buttonText,
                                  textAlign: TextAlign.center,
                                  style: TextStyle(
                                    color: Colors.black87,
                                    fontSize: fontSize != null
                                        ? fontSize
                                        : Dimensions.fontSizeLarge,
                                  )),
                        ]),
                  ),
                ))));
  }
}
